#include "../src/parser/sql_parser.h"
#include <stdio.h>
#include <stdlib.h>

int main() {
    printf("Lexer Only Test\n");
    printf("===============\n");
    
    const char* sql = "SELECT name FROM users";
    printf("Tokenizing: %s\n", sql);
    
    lexer_t* lexer = lexer_create(sql);
    if (!lexer) {
        printf("Failed to create lexer\n");
        return 1;
    }
    
    printf("Lexer created successfully\n");
    
    // Manually get tokens one by one
    int token_count = 0;
    while (token_count < 10) {  // Safety limit to prevent infinite loop
        token_t* token = lexer_next_token(lexer);
        
        if (!token) {
            printf("Token %d: NULL token (error)\n", token_count);
            break;
        }
        
        printf("Token %d: type=%d", token_count, token->type);
        if (token->value) {
            printf(", value='%s'", token->value);
        }
        printf("\n");
        
        if (token->type == TOKEN_EOF) {
            printf("Reached EOF token\n");
            token_destroy(token);
            break;
        }
        
        token_destroy(token);
        token_count++;
    }
    
    lexer_destroy(lexer);
    printf("Test completed\n");
    return 0;
}